import axios from 'axios'
export default {
  namespaced: true,
  state: {
    token: '',
    userInfo: {}
  },
  getters: {},
  mutations: {
    update(state, paylod) {
      state.token = paylod
    },
    updateInfo(state, userInfo) {
      state.userInfo = userInfo
    }
  },
  actions: {
    async getUserInfo(context) {
      // 注意：这里的this不是Vue实例化对象，而是store对象
      // console.log(this, '我要打印users里面的this')
      const { data: res } = await axios.get('/my/userinfo')
      // console.log(res, '我要打印获取用户信息里面data里面的res')
      context.commit('updateInfo', res.data)
    }
  },
  modules: {
  }
}
